<template>
  <div class="chart">
      <div ref="bar" style="width:80%;height:300px;margin:auto"></div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      
    };
  },
  computed:{
    rosedata() {
      return this.$store.state.clickeddata;
    },
    newdata(){
      return this.$store.state.clickeddata
    }
  },
  components: {},
  mounted(){
      this.dataEcharts()
  },
  watch:{
    newdata(){
      this.dataEcharts()
    },
    },
  methods: {
    dataEcharts: function (demo) {
      // 基于准备好的dom，初始化echarts实例
      var myChart = this.$echarts.init(this.$refs.bar);

      // 绘制图表
      myChart.setOption({
        title: {
          text: "柱状图分析",
        },
        tooltip: {},
        xAxis: {
          data: ["10-14",  "14-18", "18-25", "25-35","35+"],
        },
        yAxis: {},
        series: [
          {
            name: "销量",
            type: "bar",
           data: [this.rosedata.A,this.rosedata.B,this.rosedata.C,this.rosedata.D,this.rosedata.E],
           },
        ],
      });
      window.addEventListener("resize", () => {
        myChart.resize();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>